Page({
  data: {
    categories:[
      {
        label: '全部',
        id: 1
      },
      {
        label: '热带水果',
        id: 2
      },
      {
        label: '温带水果',
        id: 3
      },
      {
        label: '浆果类',
        id: 4
      },
      {
        label: '柑橘类',
        id: 5
      },
      {
        label: '瓜类',
        id: 6
      },
      {
        label: '核果类',
        id: 7
      },
      {
        label: '进口水果',
        id: 8
      },
      {
        label: '有机水果',
        id: 9
      },
      {
        label: '适合榨汁',
        id: 10
      },
      {
        label: '适合做沙拉',
        id: 11
      },
      {
        label: '适合直接食用',
        id: 12
      },
      {
        label: '季节水果',
        id: 13
      }
    ],
    item: [
      { name: "桃子", url: '../../image/fru/001.jpg', price: 10 },
      { name: "李子", url: '../../image/fru/002.jpg', price: 15 },
      { name: "苹果", url: '../../image/fru/003.jpg', price: 20 },
      { name: "橙子", url: '../../image/fru/004.jpg', price: 12 },
      { name: "橘子", url: '../../image/fru/005.jpg', price: 18 },
      { name: "芒果", url: '../../image/fru/006.jpg', price: 25 },
      { name: "柠檬", url: '../../image/fru/007.jpg', price: 8 },
      { name: "西瓜", url: '../../image/fru/008.jpg', price: 30 },
      { name: "蓝莓", url: '../../image/fru/009.jpg', price: 28 },
      { name: "樱桃", url: '../../image/fru/010.jpg', price: 35 },
      { name: "菠萝", url: '../../image/fru/011.jpg', price: 22 },
      { name: "猕猴桃", url: '../../image/fru/012.jpg', price: 16 },
      { name: "哈密瓜", url: '../../image/fru/013.jpg', price: 24 },
      { name: "椰子", url: '../../image/fru/014.jpg', price: 26 },
      { name: "荔枝", url: '../../image/fru/015.jpg', price: 14 },
      { name: "火龙果", url: '../../image/fru/016.jpg', price: 32 },
      { name: "柚子", url: '../../image/fru/017.jpg', price: 19 },
      { name: "无花果", url: '../../image/fru/018.jpg', price: 21 },
      { name: "桃子", url: '../../image/fru/019.jpg', price: 10 },
      { name: "李子", url: '../../image/fru/020.jpg', price: 15 },
      { name: "杏子", url: '../../image/fru/021.jpg', price: 17 },
      { name: "枇杷", url: '../../image/fru/022.jpg', price: 13 },
      { name: "桑葚", url: '../../image/fru/023.jpg', price: 27 },
      { name: "山竹", url: '../../image/fru/024.jpg', price: 31 },
      { name: "榴莲", url: '../../image/fru/025.jpg', price: 50 },
      { name: "木瓜", url: '../../image/fru/026.jpg', price: 23 },
      { name: "车厘子", url: '../../image/fru/027.jpg', price: 33 },
      { name: "柿子", url: '../../image/fru/028.jpg', price: 20 },
      { name: "龙眼", url: '../../image/fru/029.jpg', price: 18 }
    ],
    newItem: ''
  },
  // goto(e) { 
  //   const name=e.currentTarget.dataset.name
  //   wx.navigateTo({
  //     url: `../list/list?name=${name}`,
  //   })
  // },
  goto(e) {
    const item = e.currentTarget.dataset.item;
    console.log(item);
    wx.navigateTo({
      url: `/pages/detail/detail?title=${item.name}&image=${item.url}&price=${item.price}`
    });
    },
  selectCategory(e) {
    const id = e.currentTarget.dataset.category;
    const ranges = [[0, 9], [10, 19], [19, 28]];
    const [start, end] = ranges[id % 3];
    this.setData({
      newItem: this.data.item.slice(start, end)
    });
  },
  onLoad() {
    this.setData({
      newItem: this.data.item.slice(0,9)
    })
  }
})